package controller.listeners;

import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.util.Set;

/**
 * Created by IntelliJ IDEA.
 * User: Jason Ye
 * Date: 02/02/2012
 * Time: 17:02

 */
public class MyRelationListSelectionListener implements ListSelectionListener {
    @Override
    public void valueChanged(ListSelectionEvent evt) {

        // When the user release the mouse button and completes the selection,
        // getValueIsAdjusting() becomes false
        if (!evt.getValueIsAdjusting()) {
            JList list = (JList)evt.getSource();

            // Get all selected items
            Object[] selected = list.getSelectedValues();

            System.out.println("Selected:");
            // Iterate all selected items
            for (int i=0; i<selected.length; i++) {
                
                Object sel = selected[i];

                // change detail panel


                System.out.println(sel.toString());

            }
            

        }


    }
}
